<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="Petit FatFs" href="../00index_p.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<link rel="stylesheet" href="../css_p.css" type="text/css" media="screen" title="ELM Default">
<title>Petit FatFs - disk_writep</title>
</head>

<body>

<div class="para">
<h2>disk_writep</h2>
<p>The disk_writep function writes data to the sector.</p>
<pre>
DRESULT disk_writep (
  BYTE* <em>Buffer</em>,       /* Pointer to the data to be written */
  DWORD <em>SectorBytes</em>,  /* Sector number or Number of bytes to wtite */
);
</pre>
</div>

<div class="para">
<h4>Parameters</h4>
<dl class="par">
<dt>Buffer</dt>
<dd>Pointer to the data to be sent to the sector. If a NULL is given, the function initiate/finalize the write operation.</dd>
<dt>SectorBytes</dt>
<dd>Specifies nubmer of bytes to send if <tt>Buffer</tt> is not a NULL. If <tt>Buffer</tt> is a NULL and <tt>SectorBytes</tt> is not a zero, the function initiates a write operation to the sector. If both parameters are zero, the function finalize the current sector write operation.</dd>
</dl>
</div>


<div class="para">
<h4>Return Value</h4>
<dl class="ret">
<dt>RES_OK (0)</dt>
<dd>The function succeeded.</dd>
<dt>RES_ERROR</dt>
<dd>Any hard error occured during the disk write operation and could not recover it or the drive is write protected.</dd>
<dt>RES_PARERR</dt>
<dd>Invalid parameter.</dd>
<dt>RES_NOTRDY</dt>
<dd>The disk drive has not been initialized.</dd>
</dl>
</div>


<div class="para">
<h4>Description</h4>
<p>The sector write operation is done in following sequence.</p>
<ol>
<li><tt>disk_writep(0, sector_number);</tt> Initiate a sector write operation.</li>
<li><tt>disk_writep(data, byte_to_write);</tt> Start to send data to the sector.</li>
<li><tt>disk_writep(data, byte_to_write);</tt> And data can be sent upto 512 bytes with one or more calls.</li>
<li><tt>disk_writep(data, byte_to_write);</tt> ...</li>
<li><tt>disk_writep(0, 0);</tt> Finalize the write operation. If number of bytes sent is less than 512, left bytes in the sector is filled by zero.</li>
</ol>
<p>If a write operaion is in progress, disk_readp function will fail and disk_initialize function finalize the write operation.</p>
</div>


<div class="para">
<h4>Remarks</h4>
<p>This funciton is not needed in read-only configuration.</p>
</div>


<p class="foot"><a href="../00index_p.html">Return</a></p>
</body>
</html>
